package com.example.controller.flowable;
import com.example.service.flowable.ILeaveService;
import com.example.vo.ResultVo;
import com.example.vo.process.LeaveVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 请假控制器
 *
 * @author wsl
 */
@RestController
@Api(tags = "流程管理-请假")
@RequestMapping("/process/leave")
public class LeaveController {

    @Autowired
    private ILeaveService leaveService;

    @PostMapping("/create")
    @ApiOperation(value = "新建请假申请")
    public ResultVo createLeaveProcess(@RequestBody LeaveVo leaveVo) {
        return leaveService.createLeaveProcess(leaveVo);
    }

    @GetMapping("/assessing-officer")
    @ApiOperation(value = "审批人员列表")
    public ResultVo queryAssessingOfficer(@RequestParam String userId){
        return leaveService.queryAssessingOfficer(userId);
    }

    @PutMapping("/examine-approved")
    @ApiOperation(value = "完成请假审批")
    public ResultVo completeExamineApproved(@RequestParam(name = "taskId") String taskId,@RequestParam(name = "approved")Boolean approved,
                                            @RequestParam(name = "reply",required = false) String reply){
        return leaveService.completeExamineApproved(taskId,approved,reply);
    }

    @GetMapping("/personal-start")
    @ApiOperation(value = "查看我的请假申请")
    public ResultVo queryMyLeaveProcess(@RequestParam String userId){
        return leaveService.queryMyLeaveProcess(userId);
    }

    @GetMapping("/audit-task")
    @ApiOperation(value = "查看我的请假审批任务")
    public ResultVo queryAuditTask(@RequestParam String userId){
        return leaveService.queryAuditTask(userId);
    }

    @GetMapping("/leave-apply-detail")
    @ApiOperation(value = "查看请假申请详情")
    public ResultVo queryLeaveApplyDetail(String processInstanceId){
        return leaveService.queryLeaveApplyDetail(processInstanceId);
    }

    @GetMapping("/accreditation-detail")
    @ApiOperation(value = "查看任务详情")
    public ResultVo queryTaskDetail(String taskId){
        return leaveService.queryTaskDetail(taskId);
    }
}
